package com.manzuo.examples.showcase.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.manzuo.examples.showcase.log.TestLogService;

@Controller
public class PromotionController {
	
	@Autowired
	private TestLogService testLogService;
	
	@RequestMapping( 
			value = "/cities/{city}",
			method = RequestMethod.GET)
	public String showPromotions(@PathVariable("city") String city, Model model) {
		model.addAttribute("title", "城市-首页");
		model.addAttribute("city", city);
		testLogService.doSomeThing();
		return "promotions";
	}
	
	@RequestMapping( 
			value = "/cities/{city}/promotions/{pid}",
			method = RequestMethod.GET)
	public String showPromotion(@PathVariable("city") String city, @PathVariable("pid") Long id, Model model) {
		model.addAttribute("title", "城市-单品");
		model.addAttribute("city", city);
		model.addAttribute("id", id);
		testLogService.doSomeThing();
		return "promotions";
	}
	
}
